<?php
include_once("./_common.php");

$mta_this = "y".date("Y");

$sql = "SELECT a.store_num, a.a_name1, a.a_name2, a.a_addr1, a.a_tel, a.s_map_x, a.s_map_y, b.{$mta_this} as y_avg
          FROM manage a, month_avg b
         WHERE a.store_num = b.store_num
		   and abs(53*(a.s_map_x - '$longitude')) < 1
		   and abs(69.1*(a.s_map_y - '$latitude')) < 1
		 order by store_num ASC";
$rst = sql_query($sql);

while($row = mysql_fetch_assoc($rst))
{
	$list[] = $row;
}

$result = "";

for ($i=0; $i<count($list); $i++)
{
	$result .= $list[$i]['store_num']."<col>".$list[$i]['a_name1']."<col>".$list[$i]['a_name2']."<col>"
                    .$list[$i]['a_addr1']."<col>".$list[$i]['a_tel']."<col>".$list[$i]['s_map_x']."<col>".$list[$i]['s_map_y']."<col>"
                    .$list[$i]['y_avg']."<col>"."<col>END"."<row>";
}

echo($result);
?>